package com.xuecheng.learning.api;

import com.xuecheng.learning.model.dto.XcChooseCourseDto;
import com.xuecheng.learning.service.MyCourseTablesService;
import com.xuecheng.learning.util.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Linzkr
 * @description: TODO 我的课程表的接口
 * @date 2023/2/2 9:50
 */
@RestController
@Slf4j
@Api(value = "我的课程表接口",tags = "我的课程表接口")
public class MyCourseTablesController {
    @Autowired
    MyCourseTablesService myCourseTablesService;

    @ApiOperation("添加选课")
    @PostMapping("/choosecourse/{courseId}")
    public XcChooseCourseDto addChooseCourse(@PathVariable("courseId") Long courseId)  {
//        调用service添加选课
        SecurityUtil.XcUser user = SecurityUtil.getUser();
        String userId = user.getId();
        XcChooseCourseDto xcChooseCourseDto = myCourseTablesService.addCourseCourse(userId, courseId);
        return xcChooseCourseDto;
    }


}
